package com.work.daily.stream;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * Stream 的筛选（filter）
 *
 * @author Shengkang.Mo
 * @create 2020-11-23 16:22
 */
public class Stream_3_1 {
    public static void main(String[] args) {
        List<Integer> list = Arrays.asList(6, 7, 3, 8, 1, 2, 9);
        Stream<Integer> stream = list.stream();
        stream.filter(x -> x > 7).forEach(System.out::println);
        //stream 只能被使用一次
        List<Integer> collect = list.stream().filter(x -> x < 7).collect(Collectors.toList());
        System.out.println(collect);
    }
}
